﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class View_AddInfo : System.Web.UI.Page
{
    AccessDAO dao = new AccessDAO();
    protected void Page_Load(object sender, EventArgs e)
    {
        this.btnSubmit.Attributes.Add("onclick", "javascript:succShow();");
        IsAdmin.Admin();
        if (!Page.IsPostBack)
        {
            int typeid = Convert.ToInt32(Session["newTypeId"].ToString());
            string sql = "select * from newMessInfo where id=" + typeid;
            this.DateTimePicker1.Text = DateTime.Now.ToString();
            DataSet ds = dao.getDs(sql);
            foreach (DataRow dr in ds.Tables["message"].Rows)
            {
                this.drpType.Items.Add(dr["name"].ToString());
            }
        }
    }
    //添加
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string title = this.txtTitle.Text;

        DateTime tt = Convert.ToDateTime(this.DateTimePicker1.Text.ToString());
        string time = tt.ToShortDateString();

        string content = this.FCKeditor1.Value;
        int Typeid = Convert.ToInt32(Session["newTypeId"].ToString());

        string sql = "insert into newMessage(messId,title,newtime,content) values("+Typeid+",'"+title+"','"+time+"','"+content+"')";
        if (dao.getComm(sql) != 0)
        {
            Server.Transfer("infoMessage1.aspx");
        }
        else
        {
            RegisterStartupScript("check", "<script language='javascript'>alert('添加失败');</script>");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Server.Transfer("infoMessage.aspx");
    }
}
